package com.example.shopping.fpage;

import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.viewpager.widget.PagerAdapter;

import java.util.List;

public class FPCatagoryAdapter extends PagerAdapter {
    List<GridView>list;
    public FPCatagoryAdapter(List<GridView>list){
        this.list=list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
        return view==object;
    }

    @NonNull
    @Override
    public Object instantiateItem(@NonNull ViewGroup container, int position) {
     GridView imageView=list.get(position);
       container.addView(imageView);
       return  imageView;
    }

    @Override
    public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
      GridView imageView=list.get(position);
       container.removeView(imageView);
    }
}
